package com.adz.robotdemo.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.adz.robotdemo.R;
import com.adz.robotdemo.adapter.LVAdapter;

/**
 * Created by Administrator on 2017/6/12.
 */

public class RobotDialog extends Dialog {

    Context mContext;
    public RobotDialog(Context context) {
        super(context,R.style.dialog);
        this.mContext=context;
    }


    public void initDialog(){
        LayoutInflater inflater= LayoutInflater.from(mContext);
        View view=inflater.inflate(R.layout.layout_dialog,null);
        this.setContentView(view);
        ListView listView= (ListView) view.findViewById(R.id.lv);
       final LVAdapter adapter=new LVAdapter(mContext);
        listView.setAdapter(adapter);
        this.show();
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                String question = (String)adapter.getItem(i);
                click.onItemClick(question);
            }
        });
    }
    ItemClick click;
    public interface ItemClick{
        void onItemClick(String question);
    }

    public void setItemClick(ItemClick click){
        this.click=click;
    }


}
